<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
	<title>远程会诊系统 | Login</title>
  	<link rel="stylesheet" th:href="@{/static/assets/bootstrap/css/bootstrap.min.css}"/>
    <link rel="stylesheet" th:href="@{/static/assets/adminlte/css/login3.css}"/>
	<!--[if IE]>
		<script src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->
	<script th:inline="javascript">
            //项目根路径
            // path = /*[[@{/}]]*/'';
            ctx = [[${#request.getContextPath()}]];//应用路径
    </script>
</head>
<body>
	<section class="canvas-wrap">
        <div class='login'>
        <form class='login_fields' id="loginForm">
            <div class='login_title'>
                <span>远程会诊系统</span>
            </div>
            <div class='login_fields__user'>
              <div class='icon'>
                <img th:src='@{/static/assets/adminlte/img/user_icon_copy.png}'>
              </div>
              <input placeholder='用户名' type='text' id="username" autocomplete="off"/>
                <div class='validation'>
                  <img th:src='@{/static/assets/adminlte/img/tick.png}'>
                </div>
            </div>
            <div class='login_fields__password'>
              <div class='icon'>
                <img th:src='@{/static/assets/adminlte/img/lock_icon_copy.png}'>
              </div>
              <input placeholder='密码' type='password' id="password" autocomplete="off">
              <div class='validation'>
                <img th:src='@{/static/assets/adminlte/img/tick.png}'>
              </div>
            </div>
            <div class='login_fields__user'>
              <input placeholder='验证码' type='text' id="captcha" autocomplete="off"/>
			  <img src='/TS/api/captcha/generate' class="codeImage" id="captchaImage"/>
            </div>
            <div class='login_fields__submit'  align="center" >
              <input type='button' value='登录' onclick="formSubmit()">
            </div>
            <p class="disclaimer">
               <span id="msg"></span>
            </p>
          </form>
          <div class='success'>
            <h2>登录成功</h2>
            <a href="">Welcome back</a>
          </div>
        </div>
        <div class="authent">
          <img th:src="@{/static/assets/adminlte/img/puff.svg}">
          <p>正在登录...</p>
        </div>
        <div id="canvas" class="gradient"></div>
    </section>

    <script th:src="@{/static/assets/jquery/jquery-2.2.3.min.js}"></script>
	<!-- Main library -->
    <script th:src="@{/static/assets/adminlte/js/login3/three.min.js}"></script>
    <!-- Helpers -->
    <script th:src="@{/static/assets/adminlte/js/login3/projector.js}"></script>
    <script th:src="@{/static/assets/adminlte/js/login3/canvas-renderer.js}"></script>
    <!-- Visualitzation adjustments -->
    <script th:src="@{/static/assets/adminlte/js/login3/3d-lines-animation.js}"></script>
    <!-- rest.js -->
	<script th:src="@{/static/js/system/rest.js}"></script>
    <script type="text/javascript">
	    $(document).ready(function(){
	    	sessionStorage.removeItem('userInfo');
	    	sessionStorage.removeItem('userMenu');
	    	//解决Session过期跳出iframe框架页的问题
		    if(window !=top){  
		        top.location.href=location.href;  
		    }
	    	
	        $("#captchaImage").click(function(){
	            document.getElementById("captchaImage").src= "/TS/api/captcha/generate?" + Math.random();
	        })
	    });
	    
	    /**
	     * 登录
	     */
	    function formSubmit() {
	    	$.ajax({
                //提交数据的类型 POST GET
                type:"POST",
                //提交的网址
                url:ctx + "/api/login",
                //提交的数据  
             	data: JSON.stringify({
	            "userName": $("#username").val(),
	            "password": $("#password").val(),
	            "captcha": $("#captcha").val()
	        	}),
　　　　  		 	//参数格式为json
             	contentType: "application/json; charset=utf-8",
                //返回数据的格式
                datatype: "json",
                //成功返回之后调用的函数             
                success:function(data){
                	if (data.code == 0) {
    	            	window.location.href = ctx + '/page/index';
    	            }else{
    	            	$("#msg").text(data.message);
    	            }
                }
             })
	    }
	</script>
</body>
</html>